from typing import List
class Solution:

    def canThreePartsEqualSum(self, A: List[int]) -> bool:
        n = len(A)
        if n < 3:
            return False
        s = sum(A)
        if s % 3 != 0:
            return False
        mid = s / 3
        part_one = 0
        for i in range(0, n-2):
            part_one += A[i]
            if part_one != mid:
                continue
            part_two = 0
            for j in range(i+1, n-1):
                part_two += A[j]
                if part_two != mid:
                    continue
                part_three = s - part_one - part_two
                if part_one == part_two == part_three:
                    return True
        return False

if __name__ == "__main__":
    r = Solution().canThreePartsEqualSum([0,2,1,-6,6,-7,9,1,2,0,1])
    print(r)
